//
//  YYCollectionViewCell.m
//  LOU
//
//  Created by 要帅气的生活 on 15/11/13.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "YYCollectionViewCell.h"
#import "Head.h"

@interface YYCollectionViewCell ()

@property (nonatomic, strong) UIImageView *imageView;
@property (nonatomic, strong) UILabel *label;
@property (nonatomic, strong) UILabel *address;

@end
@implementation YYCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        _model = [Enshrine new];
        
        _imageView = [UIImageView new];
        [self addSubview:_imageView];
        
        _label = [UILabel new];
        [self addSubview:_label];
        
        _address = [UILabel new];
        [self addSubview:_address];
    }
    return self;
}
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
    _imageView.frame = CGRectMake(0, 0, self.frame.size.width, self.frame.size.width);
    _label.frame = CGRectMake(0, self.frame.size.width, self.frame.size.width/2, 50 * Height);
    _label.font = [UIFont boldSystemFontOfSize:15];
    _label.numberOfLines = 0;
    
    _address.frame = CGRectMake(self.frame.size.width/2, self.frame.size.width, self.frame.size.width/2, 50 * Height);
    _address.font = [UIFont boldSystemFontOfSize:15];
    _address.numberOfLines = 0;
    _address.textAlignment = 2;
}
- (void)setModel:(Enshrine *)model
{
    _model = model;
    _label.text = _model.title;
    _imageView.image = [UIImage imageNamed:_model.picture];
    _address.text = _model.address;
//    [_imageView sd_setImageWithURL:[NSURL URLWithString:_model.url] placeholderImage:[UIImage imageNamed:@"zhanwei"]];
}
@end
